<?php

namespace App\Model\Api;

use App\Model\BaseModel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Log;

class UserTags extends BaseModel
{
    protected $connection = 'api';
    protected $table = "user_tags";
    private $fields = ['*'];

    public function getList($limit, $page, $type, $catId=0) {
        $query = new self();
        if ($type != '') $query = $query->where('type' , $type);
        if ($catId ) $query = $query->where('cat' , $catId);
        return $query->orderBy('sort', 'desc')->paginate($limit, $this->fields, 'page', $page);
    }

    public function createUserTag(array $data = []) {
        return curl_request(getKkaudioApiUrl() . '/inner/user/create_tags', $data);
    }

    public function updateUserTag(int $id, array $data = []) {
        return curl_request(getKkaudioApiUrl() . '/inner/user/update_tags', array_merge($data, [ 'id' => $id ]));
    }
}
